import unittest
import config.path_cfg as cfg
from api.emp_api import EmpApi
from parameterized import parameterized

from common.json_schema_util import JsonSchemaUtil
from common.read_xlsx_util import ReadXlsxUtil


class TestLogin(unittest.TestCase):
    @parameterized.expand(ReadXlsxUtil.read_xlsx(cfg.BASE_DIR + '/data/iHRM.xlsx', '登录'))
    def test_login(self, case_name, body, status_code, expect_data):
        # 测试报告中显示标题和预期结果，只能用print()
        print(f'用例标题：{case_name}')
        print(f'预期结果：{expect_data}')

        resp = EmpApi().login_request(body)
        resp_data = resp.json()

        JsonSchemaUtil.json_schema(resp_data, expect_data)
